home *** CD-ROM | disk | FTP | other *** search
| Text File | 1989-05-02 | 2.8 KB | 97 lines | [TEXT/MPS ] |
- % -----------------------------------------------------------------------
- % CopyFile
- % This program demonstrate how to use Simula interface to the
- % Standard File Package.
- % The program asks for a file to copy, the name of the new file and
- % then actually copies the file. The file i/o is done using Simula
- % defined I/O.
- %
- % The program excersices the rouitines SFGetFile and SFPutFile
- % from class macPackintf. It also usees the class macSFReply that
- % holds the result from calling these two procedures respectively.
- %
- %
- % Compile the program with the command
- %
- % simcomp CopyFile
- %
- % and link it with the following command:
- %
- % simld CopyFile -toolbox -APPL
- % This sequence can be generated by entering "make copyfile"
- %
- % -----------------------------------------------------------------------
- begin
-
- external class MacPoint="::SInterfaces:MacPoint";
- external class MacSFReply="::SInterfaces:MacSFReply";
- external class MacPackIntf="::SInterfaces:MacPackIntf";
-
- ref(MacPackIntf) myMacPackIntf; ! Needs one of these ;
- ref(MacSFReply) myMacSFReply; ! Will hold the result from ;
- ! calls to PackInf ;
- ref(MacPoint) LeftUpperCorner; ! Placement of dialog box ;
-
- ref(outfile) myOutFile; ! simula files - used to copy ;
- ref(infile) myInFile;
- text array TypeList(0:0); ! A TypeList has to be a one dimensional
- ! text array with lowerindex = 0 and
- ! upperindex <= 3. Every element
- ! has to be a four character text.;
-
- LeftUpperCorner:-new MacPoint; ! LeftUpperCorner of Dialog Window;
- LeftUpperCorner.h:=20;
- LeftUpperCorner.v:=20;
-
- myMacPackIntf:- new MacPackIntf;
- TypeList(0):-copy("TEXT");
- myMacSFReply:-new MacSFReply;
- myMacPackIntf.SFGetFile(LeftUpperCorner,notext,
- 0,1,TypeList,0,myMacSFReply);
- inspect myMacSFReply do
- begin
- if Good then
- begin
- myInFile:-new infile(fname);
- if not myInFile.open(blanks(132)) then
- Error("The infile could not be opened");
- end
- else
- Error("No infile");
- end;
-
- myMacPackIntf.SFPutFile(LeftUpperCorner,"Save document as",
- notext, 0, myMacSFReply);
- inspect myMacSFReply do
- begin
- if Good then
- begin
- myOutfile:-new outfile(fname);
- if not myOutfile.open(blanks(132)) then
- Error("The outfile could not be opened");
- end
- else
- Error("No outfile");
- end;
-
- begin
- boolean longimage; ! result of inrecord: true
- ! if image was filled but
- ! no line-terminater was found.;
- ! -- use same image - no internal copying needed!--;
- myOutfile.image:-myInFile.image;
-
- longimage:=myInfile.inrecord;
- while not myInFile.endfile do
- begin
- myOutfile.setpos(myInfile.pos);
- if longimage then
- myOutfile.outrecord
- else
- myOutfile.outimage;
- longimage:=myInfile.inrecord;
- end;
- end - inner block --;
- myInFile.close;
- myOutFile.close;
- end;